/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, {Component} from 'react';
import {
  AppRegistry, Button,
  StyleSheet,
  Text,
  View
} from 'react-native';
import {NativeModules} from 'react-native';
import test from "./test";
import TitleView from "./TitleView";

export default class sxwphone extends Component {
  render() {
    return (
      <View style={styles.container}>
        <TitleView title={"登陆"}
                   backClick={this.backClick}
                   extClick={this.extClick}
                   showBack={true}
                   showExt={true}
                   url={require("./img/arrow_left_white.png")}
                   extImgUrl={require("./img/title_icon_more.png")}/>
        <Button onPress={() => this.newPage()} title={"点击"}/>
        <View style={{flex: 1, backgroundColor: '#f00'}}/>
      </View>
    );
  }

  backClick() {
    console.log(`back click`)
    alert(`back click`)
  }

  extClick() {
    console.log(`ext click`)
    alert(`ext click`)
  }

  newPage() {
    // var startHelper = NativeModules.RootViewController;
    // startHelper.newPageWithJsName("test", "test")

    // startHelper.newPageWithJsName("test","test")
    //
    // var ctl = NativeModules.RouteModule;
    // console.log(`ctl = ${ctl}`)
    // // AppRegistry.registerComponent("test",test)
    // var params = {
    //   "a": "b"
    // }
    // ctl.newPageWithJsName("test", "test", params);

    var moduleName = `test`;
    route.newPageWithJsName("test", moduleName, params);
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('root', () => sxwphone);
